package com.yc.web;

import com.yc.bean.Result;
import com.yc.biz.BizException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Component
@RestControllerAdvice
public class ExHandler {

    @ExceptionHandler(BizException.class)
    public Result handleBizException(BizException e) {
        return new Result(0,e.getMessage(), e.getData());
    }

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        e.printStackTrace();
        // 后台通知管理员 Or 客服处理问题（邮件，短信。。。）
        return new Result(0,"业务繁忙，稍后再试",null);
    }

}